# 绝对引用，使我们的celery模块不会与原始的celery冲突
from __future__ import absolute_import, unicode_literals
# 导入原始的celery模块中shared_task    from xx import xx
from celery import shared_task
# 使用django内置函数发送邮件
from django.core.mail import send_mail
# 导入django的settings
from django.conf import settings


@shared_task
def send_mail_task(username, email, token):
    """
    使用django内置函数发送邮件
    """
    subject = '美多商城会员注册'
    message = ''
    from_email = settings.EMAIL_FROM
    recipient_list = [email]
    html_message = "{},欢迎注册美多商城会员，请点击以下链接进行激活：<br /> <a href='http://127.0.0.1:8000/app01/active/?token={}'>激活会员请点击</a>".format(
        username, token)
    send_mail(subject, message, from_email, recipient_list,
              html_message=html_message)